/**
  * 功能描述: 基础数字输入框样式表
  * @author 崔孝楠
  * @date 2022/9/20 17:31
  * @version 1.0
  */
@import '../../style/index';
// 数字输入框布局
@mixin input-number--layout {
  position: relative;
  box-sizing: border-box;
  margin: 0;
  display: inline-block;
  min-width: 0;
  line-height: $line-height-base;
  padding: 0;
  width: 100%;
}
// large 布局
@mixin input-number-lg--layout {
  padding: 0;
  // 输入框
  input {
    height: 38px;
  }
}
// 上下按钮布局
@mixin input-number-handler--layout {
  position: relative;
  display: block;
  width: 100%;
  height: 50%;
  overflow: hidden;
  line-height: 0;
  text-align: center;
}
// 上下按钮内部布局
@mixin input-number-handler-inner--layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: auto;
  margin-right: 0;
  line-height: 12px;
  text-align: center;
  text-transform: none;
  vertical-align: -0.125em;
  position: absolute;
  right: 4px;
  width: 12px;
  height: 12px;
  // 所有子元素
  > * {
    line-height: 1;
  }
  // svg图标
  svg {
    display: inline-block;
  }
  // 前置子元素
  &::before {
    display: none;
  }
  // 图标
  .#{$namespace}-input-number-handler-up-inner-icon,
  .#{$namespace}-input-number-handler-down-inner-icon {
    display: block;
  }
}
// 按钮禁用
@mixin input-number-disabled-handler-wrap--layout {
  display: none;
}
// 输入框布局
@mixin input-number-input--layout {
  width: 100%;
  height: 30px;
  padding: 0 11px;
  text-align: left;
}
// 按钮容器布局
@mixin input-number-handler-wrap--layout {
  position: absolute;
  top: 0;
  right: 0;
  width: 22px;
  height: 100%;
  // 悬浮
  &:hover {
    @include b(input-number-handler) {
      height: 40%;
    }
  }
}
// 悬浮向上按钮布局
@mixin input-number-handler-up-hover--layout {
  height: 60% !important;
}
// 向下按钮布局
@mixin input-number-handler-down--layout {
  top: 0;
}
// 向下按钮内部布局
@mixin input-number-handler-down-inner--layout {
  top: 50%;
  text-align: center;
}
// 样式相关
@include b(input-number) {
  font-variant: tabular-nums;
  list-style: none;
  font-feature-settings: 'tnum';
  color: $color-text-primary;
  font-size: $font-size-base;
  background-color: $color-white;
  background-image: none;
  border: $border-base;
  border-radius: $border-radius-small;
  transition: all 0.3s;
  @include input-number--layout;
  // 占位符样式
  @include placeholder {
    color: $color-text-placeholder;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    opacity: 1;
  };
  // 占位符布局
  &:placeholder-shown {
    text-overflow: ellipsis;
  }
  // 聚焦样式
  &-focused {
    border-color: $color-primary;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
    border-right-width: $border-width-base !important;
    outline: 0;
    // 聚焦时控制按钮显示
    @include b(input-number-handler-wrap) {
      opacity: 1;
    }
  }
  // 悬浮样式
  &:hover {
    border-color: $color-primary;
    border-right-width: $border-width-base !important;
    // 图标
    + .#{$namespace}-form-item-children-icon {
      opacity: 0;
      transition: opacity 0.24s linear 0.24s;
    }
    // 控制按钮显示
    @include b(input-number-handler-wrap) {
      opacity: 1;
    }
  }
  // 禁用样式
  &[disabled] {
    color: $disabled-color-base;
    background-color: $background-color-base;
    border-color: $border-color-base;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 1;
  }
  // 禁用时悬浮样式
  &[disabled]:hover {
    border-color: $border-color-base;
    border-right-width: $border-width-base !important;
  }

}
// large 样式
@include b(input-number-lg) {
  font-size: $font-size-medium;
  @include input-number-lg--layout;
}
// small 布局
@include b(input-number-sm) {
  padding: 0;
  // 输入框
  input {
    height: 22px;
    padding: 0 7px;
  }
}
// 上下按钮样式
@include b(input-number-handler){
  color: $color-text-secondary;
  font-weight: bold;
  border-left: $border-base;
  transition: all 0.1s linear;
  @include input-number-handler--layout;
  // 点击样式
  &:active {
    background: $background-color-base;
  }
}
// 按钮内部样式
.#{$namespace}-input-number-handler-up-inner,
.#{$namespace}-input-number-handler-down-inner {
  font-style: normal;
  font-size: 7px;
  text-rendering: optimizelegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: $color-text-secondary;
  transition: all 0.1s linear;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  @include input-number-handler-inner--layout;
}
// 禁用样式
@include b(input-number-disabled) {
  color: $font-color-disabled-base;
  background-color: $background-color-base;
  border-color: $border-color-base;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 1;
  // 悬浮样式
  &:hover {
    border-color: $border-color-base;
    border-right-width: $border-width-base !important;
  }
  // 内部输入框样式
  @include b(input-number-input) {
    cursor: not-allowed;
  }

  @include input-number-disabled-handler-wrap--layout;
}
// 内部输入框样式
@include b(input-number-input) {
  background-color: transparent;
  border: 0;
  border-radius: $border-radius-small;
  outline: 0;
  transition: all 0.3s linear;
  -webkit-appearance: textfield !important;
  -moz-appearance: textfield !important;
  appearance: textfield !important;
  @include input-number-input--layout;
  // 占位符
  @include placeholder {
    opacity: 1;
    color: $color-text-placeholder;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
  }
  // 占位符布局
  &:placeholder-shown {
    text-overflow: ellipsis;
  }
}
// 上下按钮容器样式
@include b(input-number-handler-wrap) {
  background: $color-white;
  border-radius: 0 2px 2px 0;
  opacity: 0;
  transition: opacity 0.24s linear 0.1s;
  @include input-number-handler-wrap--layout;
}
// 向上按钮样式
@include b(input-number-handler-up) {
  border-top-right-radius: $border-radius-small;
  cursor: pointer;
  // 悬浮样式
  &:hover {
    @include input-number-handler-up-hover--layout;
  }
}
// 按钮内部样式
@include b(input-number-handler-up-inner) {
  top: 50%;
  margin-top: -5px;
  text-align: center;
}
// 向下按钮样式
@include b(input-number-handler-down) {
  cursor: pointer;
  border-top: $border-base;
  border-bottom-right-radius: $border-radius-small;
  @include input-number-handler-down--layout;
  // 悬浮样式
  &:hover {
    @include input-number-handler-up-hover--layout;
  }
}
// 按钮内部样式
@include b(input-number-handler-down-inner) {
  @include input-number-handler-down-inner--layout;
  transform: translateY(-50%);
}
// 按钮禁用样式
.#{$namespace}-input-number-handler-up-disabled,
.#{$namespace}-input-number-handler-down-disabled {
  cursor: not-allowed;
  // 悬浮样式
  :hover {
    .#{$namespace}-input-number-handler-up-inner,
    .#{$namespace}-input-number-handler-down-inner {
      color: $font-color-disabled-base;
    }
  }
}
